package com.cip.email.picasa.api;

import static org.apache.commons.lang.StringUtils.equalsIgnoreCase;
import static org.apache.commons.lang.StringUtils.startsWith;

import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.gdata.data.photos.AlbumEntry;

public class PicasaFunctions {
	public static Predicate<AlbumEntry> isTestAlbum() {
		return new Predicate<AlbumEntry>() {

			@Override
			public boolean apply(AlbumEntry input) {
				return startsWith(getAlbumTitle().apply(input), "testAlbum");
			}
		};
	}
	
	public static Function<AlbumEntry, String> getAlbumTitle() {
		return new Function<AlbumEntry, String>() {
			@Override
			public String apply(AlbumEntry input) {
				return input.getTitle().getPlainText();
			}
		};
	}
	
	public static Predicate<AlbumEntry> byName(final String name) {
		return new Predicate<AlbumEntry>() {

			@Override
			public boolean apply(AlbumEntry input) {
				return equalsIgnoreCase( input.getTitle().getPlainText(), name);
			}
		};
	}
}
